package com.neuedu.wemall.seller.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.neuedu.wemall.common.vo.ResponseData;
import com.neuedu.wemall.dao.entity.Product;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import com.neuedu.wemall.service.IProductService;

/**
 * Author lu
 * Date   2025-09-14 21:16:19
 */
@Log4j2
@RequestMapping("/wemall/seller/product/api")
@RestController
@Tag(name = "商品控制器")
public class ProductController {

    @Autowired
    @Qualifier("productService")
    private IProductService productService;

    /**
     * 商品分页查询
     * @param pageNum  当前页码
     * @param pageSize 每页记录数
     * @param keyword  搜索关键词
     * @param product  商品查询条件
     * @return
     */
    @GetMapping("/list")
    @Operation(summary = "获取商品分页查询")
    @Parameters({
            @Parameter(name = "pageNum", description = "当前页码", required = true),
            @Parameter(name = "pageSize", description = "每页记录数", required = true),
            @Parameter(name = "keyword", description = "搜索关键词", required = false),
            @Parameter(name="catId1",description = "一级分类ID",required = false),
            @Parameter(name="catId2",description = "二级分类ID",required = false),
            @Parameter(name="status",description = "商品状态",required = false)
    })
    public ResponseData  getPageList(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                     @RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
                                     @RequestParam(value = "keyword",required = false) String keyword,
                                     @Parameter(hidden = true) Product product) {
        Page<Product> page = productService.selectPageList(pageNum,pageSize,keyword,product);
        return ResponseData.success(page);
    }

}